<%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2024/8/6
  Time: 10:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="/student?method=add" method="post">
        用户名：<input type="text" name="name"><br>
        年龄：<input type="text" name="age"><br>
        性别：<input type="text" name="gender"><br>
        班级：<select id="banjiId" name="banjiId">
                <option>--请选择班级--</option>
             </select> <br>
        <input type="submit" value="添加">
    </form>

    <script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script>
        $(function () {
            $.post(
                '/banji?method=selectAll',
                function (jsonObj) {
                    console.log(jsonObj);
                    $(jsonObj).each(function () {
                        //this
                        //{id: 1, name: 'java18073', address: '北京'}
                        $('#banjiId').append('<option value="'+this.id+'">'+this.name+'</option>');
                    })
                },
                'json'
            );
        });
    </script>
</body>
</html>
